package com.umgsai.thread.thread56;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class Main {
	static public class MyTask extends TimerTask{
		@Override
		public void run() {
			System.out.println("开始运行，时间：" + new Date());
		}
		public static void main(String[] args) {
			try {
				MyTask task = new MyTask();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Timer timer = new Timer();
				String dateString = "2016-07-09 22:17:55";
				Date date = sdf.parse(dateString);
				System.out.println("main开始执行时间：" + new Date());
				timer.schedule(task, date, 4000);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
